<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="configurationDetail.title"/></title>
    <meta name="heading" content="<fmt:message key='configurationDetail.heading'/>"/>
</head>

<div id="left">
	<fmt:bundle basename="ApplicationResources"><fmt:message key="configuration.form.page.title"/></fmt:bundle>
	<fmt:bundle basename="ApplicationResources"><fmt:message key="configuration.form.page.body"/></fmt:bundle>
	<div id="infobox">
	<s:form id="configurationForm" action="saveConfiguration" method="post" validate="true">
    <fieldset><legend><fmt:bundle basename="ApplicationResources"><fmt:message key="configuration.global.form.fieldset.title"/></fmt:bundle></legend>
    
      <div class="notes">
        <fmt:bundle basename="ApplicationResources"><fmt:message key="configuration.form.help.title"/></fmt:bundle>	        
		<fmt:bundle basename="ApplicationResources"><fmt:message key="configuration.form.help.body"/></fmt:bundle>
      </div>
	      
      <s:iterator value="configurations" id="prop">
      	  <s:set name="title" value="%{#prop.key + '.title&'}" />
     	 	
	      <div class="required format">      
	        <label><fmt:bundle basename="ConfigurationResources"><fmt:message key="${title}"/></fmt:bundle></label>
			<s:textfield name="%{'configurations[\\'' + #prop.key +'\\']'}"  cssClass="inputText" theme="simple" value="%{#prop.value}"/>
	      </div>
	     
	  </s:iterator>
	      
	</fieldset>	
	

    <fieldset>
      <div class="submit">
        <div>
          <a class="button" onclick="javascript:submitConfigurationForm();"><span><fmt:bundle basename="ApplicationResources"><fmt:message key="form.submit"/></fmt:bundle></span></a> 
          <a class="button" onclick="javascript:resetConfigurationForm();"><span><fmt:bundle basename="ApplicationResources"><fmt:message key="form.cancel"/></fmt:bundle></span></a>
        </div>
      </div>
    </fieldset>	
		
	<fieldset id="plugins"><legend><fmt:bundle basename="ApplicationResources"><fmt:message key="configuration.plugins.form.fieldset.title"/></fmt:bundle></legend>
	
	<script type="text/javascript">
		$.ajax({
		  url: "/bridge/consoleServlet?command=listAsync",
		  cache: false,
		  success: function(html){
		    $("#plugins").append(html);
		  }
		});
	</script>
	
	</fieldset>
	
	</s:form>
	</div>								
</div>

<script type="text/javascript">
    // Form.focusFirstElement($("configurationForm"));
    
    function submitConfigurationForm() {
	$("#configurationForm").attr("action","/saveConfiguration${application_theme}.html");	
	$("#configurationForm").submit();
}

function resetConfigurationForm() {
	$("#configurationForm").attr("action","/applicationConfiguration${application_theme}.html");
	$("#configurationForm").submit();
}
</script>